/*
 * Copyright 2003-2012 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package guoanmaker.operator.helper.common.util;

import java.util.Collection;
import java.util.Map;
import java.util.regex.Pattern;

public abstract class Assert {
	private static final String ARGUMENT_IS_REQUIRED_MSG = "此参数是必需的,不能为null";
	private static final String TEXT_IS_REQUIRED_MSG = "此字符串必须包含文字文本内容。不能为null,空串或仅由空白字符组成";
	private static final String MUST_BETWEEN_MSG = "value必须在min和max之间,value[%s],min[%s],max[%s]";
	private static final String ARRAY_IS_NOT_EMPTY_MSG = "数组不能为空: 它至少要包含一个元素";
	private static final String COLLECTION_IS_NOT_EMPTY_MSG = "容器不能为空: 它至少要包含一个元素";
	private static final String MAP_IS_NOT_EMPTY_MSG = "Map不能为空: 它至少要包含一个元素";
	private static final String ARRAY_NOT_CONTAIN_NULL_ELEMENT_MSG = "数组中不可包含null元素";
	private static final String IS_INSTANCE_OF_MSG = "对象 [%s] 必须是%s类的实例";
	private static final String NOT_MATCH_PATTERN_MSG = "字符串[%s]不能与模式[%s]相匹配";
	private static final String MUST_BE_TRUE_MSG = "表达式结果必须为true";

	private static final String CLASS_IS_NOT_NULL_MSG = "类型参数不能是null";

	/**
	 * 断言对象不为空
	 * 
	 * @param object
	 *            被断言对象
	 * @param message
	 *            错误消息文本
	 */
	public static void notNull(Object object, String message) {
		if (object == null) {
			throw new IllegalArgumentException(message);
		}
	}

	/**
	 * 断言对象不为空
	 * 
	 * @param object
	 *            被断言对象
	 */
	public static void notNull(Object object) {
		notNull(object, ARGUMENT_IS_REQUIRED_MSG);
	}

	
}
